#ifndef __SPEEDMEASURE_H__
#define __SPEEDMEASURE_H__

class SpeedMeasure
{
public:
	SpeedMeasure();
	virtual ~SpeedMeasure(){}

	void Add(int nTotal);
	void Measure();
	int GetSpeed();
	void Clear();

private:

#define METER_MINIMUM 100   // If the current slot is less than a tenth of a second old, record more bytes transferred there
#define METER_LENGTH  64    // Number of slots in the bandwidth meter, used to be 24, now 64
#define METER_PERIOD  1  // The bandwidth meter holds onto information for 1 seconds

	typedef struct
	{
		int	nMeasure;		// The average speed in bytes per second over the last 2 seconds

		// The arrays of byte counts and times
		int	pHistory[64];	// 64 records of a number of bytes transferred
		int	pTimes[64];		// The times each of these transfers happened
		int	nPosition;		// The next spot in the array to use
		int	tLastSlot;		// When we started using this time slot
		//ms

	} BandwidthMeter;

	BandwidthMeter m_bwMeter;
};

#endif//__SPEEDMEASURE_H__